package com.example.adapter;

import javax.crypto.spec.IvParameterSpec;

import com.example.weatherforcast.R;
import android.R.layout;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MainAdapter extends BaseAdapter {
private String me[];
Context  context;
	public MainAdapter(String[] me,Context context) {
	super();
	this.context=context;
	this.me = me;
}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return me.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return me[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View view=convertView;
		TextView tv_weather;
		ImageView iv_temp1 = null,iv_temp2=null,iv_temp3=null;
		Hondle hondle=null;
		if (view==null) {
			view=LayoutInflater.from(context).inflate(R.layout.list_main, null);
			hondle=new Hondle();
			 tv_weather=(TextView) view.findViewById(R.id.tv_weather);
			 iv_temp1=(ImageView) view.findViewById(R.id.iv_temp1);
			 iv_temp2=(ImageView) view.findViewById(R.id.iv_temp2);
			 iv_temp3=(ImageView) view.findViewById(R.id.iv_temp3);
			hondle.tv_weather=tv_weather;
			hondle.iv_temp1=iv_temp1;
			hondle.iv_temp2=iv_temp2;
			hondle.iv_temp3=iv_temp3;
		
			view.setTag(hondle);
		}else {
			hondle=(Hondle) view.getTag();
		}
		tv_weather=hondle.tv_weather;
		iv_temp1.setImageResource(R.drawable.org4_widget_nw2);
		iv_temp2.setImageResource(R.drawable.org4_widget_nw3);
		tv_weather.setText(me[position]);
		return view;
	}
	
	
	public class Hondle{
		TextView  tv_weather;
		ImageView iv_temp1;
		ImageView  iv_temp2;
		ImageView  iv_temp3;
		
	}

}
